#include<bits/stdc++.h>
using namespace std;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	long long n,l,r,o,ans;
	scanf("%lld%lld%lld",&n,&l,&r);
	ans=r%n;
	o=r/n*n-1;
	if(o>=l&&o<=r) ans=max(ans,o%n);
	printf("%lld",ans);
	return 0;
}

